package com.shihb.chapter07designpattern.observer

/**
 * Description:
 * Version:1.0.0
 *
 * @author shihb
 * @date 2020/10/4 10:49
 */
object Test {
  def main(args: Array[String]): Unit = {
    val station = new WeatherStation
    val obserber1: Obserber = new Obserber {
      override def update(weather: String): Unit = {
        println("观察者1天气报告:" + weather)
      }
    }
    val obserber2: Obserber = new Obserber {
      override def update(weather: String): Unit = {
        println("观察者2天气报告:" + weather)
      }
    }
    station.registerObserver(obserber1)
    station.set("马上要下雨了")
    station.registerObserver(obserber2)

    station.set("雨后天晴")
  }

}
